From: Camila Ayres Date: Mon, 20 Jan 2025 14:00:43 +0000 (+0100) Subject: Look for previous used application name for config folder. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~2^2~69^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success/%22http:/www.example.com/cgi/success?a=commitdiff_plain;h=5236b1bc92e544f0e37758edadf1305433821408;p=nextcloud-desktop.git Look for previous used application name for config folder. oldDir => legacyDataDir. Signed-off-by: Camila Ayres --- diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 10bf7cfaa..641f32c74 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -240,14 +240,14 @@ Application::Application(int &argc, char **argv) setWindowIcon(_theme->applicationIcon()); if (!ConfigFile().exists()) { - // Migrate from version <= 2.4 setApplicationName(_theme->appNameGUI()); - // We need to use the deprecated QDesktopServices::storageLocation because of its Qt4 - // behavior of adding "data" to the path - QString oldDir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/data/" + organizationName() + "/" + applicationName(); - if (oldDir.endsWith('/')) oldDir.chop(1); // macOS 10.11.x does not like trailing slash for rename/move. + QString legacyDir = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/" + APPLICATION_CONFIG_NAME; + + if (legacyDir.endsWith('/')) { + legacyDir.chop(1); // macOS 10.11.x does not like trailing slash for rename/move. + } setApplicationName(_theme->appName()); - if (QFileInfo(oldDir).isDir()) { + if (QFileInfo(legacyDir).isDir()) { auto confDir = ConfigFile().configPath(); // macOS 10.11.x does not like trailing slash for rename/move. @@ -255,17 +255,17 @@ Application::Application(int &argc, char **argv) confDir.chop(1); } - qCInfo(lcApplication) << "Migrating old config from" << oldDir << "to" << confDir; + qCInfo(lcApplication) << "Migrating old config from" << legacyDir << "to" << confDir; - if (!QFile::rename(oldDir, confDir)) { - qCWarning(lcApplication) << "Failed to move the old config directory to its new location (" << oldDir << "to" << confDir << ")"; + if (!QFile::rename(legacyDir, confDir)) { + qCWarning(lcApplication) << "Failed to move the old config directory to its new location (" << legacyDir << "to" << confDir << ")"; // Try to move the files one by one if (QFileInfo(confDir).isDir() || QDir().mkdir(confDir)) { - const QStringList filesList = QDir(oldDir).entryList(QDir::Files); + const QStringList filesList = QDir(legacyDir).entryList(QDir::Files); qCInfo(lcApplication) << "Will move the individual files" << filesList; for (const auto &name : filesList) { - if (!QFile::rename(oldDir + "/" + name, confDir + "/" + name)) { + if (!QFile::rename(legacyDir + "/" + name, confDir + "/" + name)) { qCWarning(lcApplication) << "Fallback move of " << name << "also failed"; } } @@ -273,7 +273,7 @@ Application::Application(int &argc, char **argv) } else { #ifndef Q_OS_WIN // Create a symbolic link so a downgrade of the client would still find the config. - QFile::link(confDir, oldDir); + QFile::link(confDir, legacyDir); #endif } }